import Mock from 'mockjs';

const data = [
  {
    id: 1,
    parentId: 0,
    deptName: '深圳市安徽尚礼科技有限公司',
    deptStatus: 0,
    count: 0,
    organizationTreeVo: [
      {
        id: 4,
        parentId: 1,
        deptName: '技术研发部（96人）',
        deptStatus: 0,
        organizationTreeVo: [
          {
            id: 9,
            parentId: 4,
            deptName: '前端原生部（2 人）',
            deptStatus: 0,
          },
          {
            id: 10,
            parentId: 4,
            deptName: '后台开发部（94 人）',
            deptStatus: 0,
          },
        ],
      },
      {
        id: 2,
        parentId: 1,
        deptName: '后台开发部（94 人）',
        deptStatus: 0,
        organizationTreeVo: [
          {
            id: 5,
            parentId: 2,
            deptName: '二级 2-1',
            deptStatus: 0,
          },
          {
            id: 6,
            parentId: 2,
            deptName: '二级 2-2',
            deptStatus: 0,
          },
        ],
      },
      {
        id: 3,
        parentId: 1,
        deptName: '后台开发部111（94 人）',
        deptStatus: 0,
        organizationTreeVo: [
          {
            id: 7,
            parentId: 3,
            deptName: '二级 3-1',
            deptStatus: 0,
          },
          {
            id: 8,
            parentId: 3,
            deptName: '二级 3-2',
            deptStatus: 0,
          },
        ],
      },
    ],
  },
];

export default [
  {
    url: '/bnd-organization/organizationTree/selectOrganizationTree/.*',
    type: 'get',
    response: () => {
      return { status: 200, msg: 'success', data };
    },
  },
  {
    url: '/organization/search',
    type: 'post',
    response: () => {
      const searchData = Mock.mock({
        'deptList|2-5': [
          {
            id: '@id',
            deptName: '部门-@integer(0, 100)',
          },
        ],
        'userList|4-8': [
          {
            id: '@id',
            deptName: '人员-@integer(0, 100)',
          },
        ],
      });
      return { status: 200, msg: 'success', data: searchData };
    },
  },
  {
    url: '/bnd-organization/organizationDept/selectDeptStaff',
    type: 'post',
    response: res => {
      const { current = 1, size = 10 } = res.body;
      const { users } = Mock.mock({
        'users|10': [
          {
            departmentId: '@id', // 部门id
            id: '@id', // 主键id
            mobilePhone: /^1[3578]\d{9}$/, // 电话号码
            organizationGroupCodeId: 1, // 企业组唯一id
            organizationId: 1, // 企业id
            parentDepartment: '@id', // 上级用户部门id
            parentId: '@id', // 上级id
            parentName: '上级-@integer(1,100)', // 上级名称
            pricipalStatus: '@integer(0, 1)', // 是否是部门负责人(0:否,1:是)
            realName: '姓名-@integer(1,100)', // 真实姓名
            state: '@integer(0, 1)', // 禁用标识(0:禁用,1:启用)
            userId: '工号-@integer(1, 100)', // 用户id
            userStatus: '@integer(0, 2)', // 员工使用状态 0：使用中 1：终止合作 2：已注销
            userStatusDetails: 0, // 使用状态detail
            cacelTime: '@date("yyyy-MM-dd")', // 注销时间
            cacelTimeFormat: '',
            createBy: 0,
            createTime: '@date("yyyy-MM-dd")',
            createTimeFormat: '@date("yyyy-MM-dd")',
            createUsername: '创建人-@integer(1,100)',
            updateBy: 0,
            updateTime: '',
            updateUsername: '',
          },
        ],
      });

      return {
        status: 200,
        data: {
          records: users,
          current,
          size,
          total: 40,
        },
        message: 'success',
      };
    },
  },
  {
    url: '/bnd-organization/organization/findCompanyInfoAuthenticationById/.*',
    type: 'get',
    response: () => {
      return { status: 200, msg: 'success', data: false };
    },
  },
];
